package cn.edu.stu.syllabus.utils;

import android.os.Build;
import android.support.v4.widget.SwipeRefreshLayout;

import cn.edu.stu.syllabus.R;
import cn.edu.stu.syllabus.base.BaseActivity;

/**
 * Created by liyujie on 2017/4/20.
 */

public class SwipeLayoutOffsetUtils {

    public static void downSwipeLayoutOffset(BaseActivity activity, SwipeRefreshLayout swipeRefreshLayout) {
        int addOffset = activity.getResources().getDimensionPixelSize(R.dimen.toolbarHeight);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            addOffset = addOffset + DensityUtil.px2dip(activity.getStatusBarHeight());
        }
        int startOffset = swipeRefreshLayout.getProgressViewStartOffset();
        int endOffset = swipeRefreshLayout.getProgressViewEndOffset();
        swipeRefreshLayout.setProgressViewOffset(false, startOffset + addOffset, endOffset + addOffset);
    }
}
